#include "reports.h"
#include "ui_reports.h"
#include<QDesktopWidget>
#include<QDebug>
#include<QtSql/QSqlQuery>
#include<QFile>
#include<QTextStream>
//This class represnts list of types of reports like daily,weekly,monthly,yearly
Reports::Reports(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::Reports)
{
    ui->setupUi(this);
    QRect q=QApplication::desktop()->availableGeometry(this);
    ui->scrollArea->setGeometry(0,0,(q.width()),(q.height()));
    //ui->listWidget->setGeometry(0,0,q.width(),q.height());
    ui->listWidget->setEditFocus(true);
    int fontSize=10;//(q.width()/30.0);
    QAction* backAction = new QAction( tr("Back"), this );
     backAction->setSoftKeyRole( QAction::NegativeSoftKey );
     connect(backAction, SIGNAL(triggered()), this, SLOT(back()));
     addAction( backAction );

    item1=new QListWidgetItem("Daily",ui->listWidget,QListWidgetItem::UserType);
    item1->setFont(QFont( "lucida", fontSize, QFont::Normal, FALSE ));

    item2=new QListWidgetItem("Weekly",ui->listWidget,QListWidgetItem::UserType);
    item2->setFont(QFont( "lucida", fontSize, QFont::Normal, FALSE ));

    item3=new QListWidgetItem("Monthly",ui->listWidget,QListWidgetItem::UserType);
    item3->setFont(QFont( "lucida", fontSize, QFont::Normal, FALSE ));

    item4=new QListWidgetItem("Yearly",ui->listWidget,QListWidgetItem::UserType);
    item4->setFont(QFont( "lucida", fontSize, QFont::Normal, FALSE ));
  /*  if(db.db_connect())
    { QSqlQuery q;
        if(q.exec(QString("select name from account_table")))
        {
            while(q.next())
           qDebug()<<q.value(0).toString();
        }
        QFile f("C:\\Data\\log1.txt");

        if(f.open(QIODevice::Append))
        {
            QTextStream t(&f);
            t<<"In reports";
        }
        db.db_close();
    }*/
}

Reports::~Reports()
{
    delete ui;
}
void Reports::back()
{
    (new expense)->show();

}

void Reports::on_listWidget_itemActivated(QListWidgetItem* item)
{
    if(item==item1)
    {
       (new ExpDaily)->show();
    }
    else if(item==item2)
    {
        (new ExpWeek)->show();
    }
    else if(item==item3)
    {
        (new ExpMonth(1,2))->show();
    }
    else if(item==item4)
    {
        (new ExpMonth(2,2))->show();
    }
}
